/**
  ******************************************************************************
  * @file    RS232_Driver.c
  * @author  tuancheng_Zero
  * @version V0.1
  * @date    08/05/2024
  * @brief   RS232 Driver
  ******************************************************************************
*/ 
#ifndef  __RS232_DRIVER_H__
#define  __RS232_DRIVER_H__

#ifdef __cplusplus
extern "C" {
#endif

// RS232中断配置
#define RS232_IRQn               UART6_IRQn
#define RS232_IRQHandler 		 UART6_IRQHandler

// RS232串口配置
#define RS232_UART              UART6
#define RS232_GPIO              GPIOE
// #define RS232_BaudRate          115200
#define RS232_BaudRate          256000
#define RS232_CLK               RCC_APB2_PERIPH_UART6
#define RS232_GPIO_CLK          RCC_APB2_PERIPH_GPIOE
#define RS232_RxPin             GPIO_PIN_3
#define RS232_TxPin             GPIO_PIN_2
#define RS232_DMA_DR_Base       ((uint32_t)&UART6->DAT)

// RS232DMA配置
#define RS232_DMA               DMA2
#define RS232_DMA_Rx_IRQn       DMA2_Channel1_IRQn
#define RS232_DMA_Tx_IRQn       DMA2_Channel2_IRQn
#define RS232_Tx_DMA_Channel    DMA2_CH2
#define RS232_Tx_DMA_FLAG       (DMA2_FLAG_GL2|DMA2_FLAG_TC2|DMA2_FLAG_TE2|DMA2_FLAG_HT2)
#define RS232_Rx_DMA_Channel    DMA2_CH1
#define RS232_Rx_DMA_FLAG       (DMA2_FLAG_GL1|DMA2_FLAG_TC1|DMA2_FLAG_TE1|DMA2_FLAG_HT1)  
#define RS232_Tx_DMA_Function   DMA2_Channel2_IRQHandler
#define RS232_Rx_DMA_Function   DMA2_Channel1_IRQHandler

void RS232_Init(void);
uint8_t RS232_DmaTransferData(uint8_t * pData, uint16_t length);

#ifdef __cplusplus
}
#endif
#endif   /*   __EXTEND_PRIMEMOTOR_DRIVER_H__   */
